package cn.mong.util.modelexcel.vo;

import java.util.Arrays;
import java.util.List;

import cn.mong.util.modelexcel.ExcelCol;
import cn.mong.util.modelexcel.ModelToCellsConverter;
import cn.mong.util.modelexcel.PositionCell;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public  class RouteInfo{
	@ExcelCol(name="配属所", index=1)
	private String trh;

	@ExcelCol(name="车型", index=2)
	private String model;

	@ExcelCol(name="车次", index=3)
	private List<String> tnos;

	@ExcelCol(name="交路天", index=4, subClass=DayRoute.class )
	private List<DayRoute> days;

	@ExcelCol(name="开行情况", index=5)
	private String runInfo;


	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	public static class DayRoute{
		@ExcelCol(name="交路天", index=1)
		private String daySeq;

		@ExcelCol(name="车次及时刻", index=2,
				modelToCellsHorizontal = true, modelToCellsConverter = MyModelToCellsConverter.class)
		List<TNumber> trainNos;
	}

	@Data
	@AllArgsConstructor
	@NoArgsConstructor
	public static class TNumber{
		private String tn;
		private String mile;
		private String startSt;
		private String endSt;
		private String startTime;
		private String endTime;

	}

	public static class MyModelToCellsConverter implements ModelToCellsConverter<TNumber>{

		@Override
		public List<? extends PositionCell> modelToValCells(TNumber model) {
			return Arrays.asList(new PositionCell(0, 0, model.getTn(), 2, 1, 15)
					, new PositionCell(1, 0, model.getMile(), 2, 1, 15)
					, new PositionCell(2, 0, model.getStartSt(), 1, 1, 15)
					,  new PositionCell(2, 1, model.getEndSt(), 1, 1, 15)
					,  new PositionCell(3, 0, model.getStartTime(), 1, 1, 15)
					,  new PositionCell(3, 1, model.getEndTime(), 1, 1, 15)
					);
		}

	}

}
